package com.ibm.risk.irmp.base.auth.rest;

import com.ibm.risk.irmp.common.auth.session.UserSessionStore;
import com.ibm.risk.irmp.common.auth.vo.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/v2/auth/session")
@Slf4j
public class UserSessionStoreController {// implements UserSessionStore{
    @Autowired
    private UserSessionStore userSessionStore;

    @GetMapping("/tokens/{token}")
    public LoginUser getLoginUser(@PathVariable String token)
    {
        return userSessionStore.getLoginUser(token);
    }


    @PutMapping("/tokens/{token}")
    public void setLoginUser(@PathVariable String token, @RequestBody LoginUser loginUser) {
        userSessionStore.setLoginUser(token, loginUser);
    }
}
